package com.ccys.doctor.service.impl;

import com.ccys.db.cache.UserUtil;
import com.ccys.db.entity.TblDoctorAcronyms;
import com.ccys.db.mapper.TblDoctorSupportTabReadMapper;
import com.ccys.db.page.AppPageDto;
import com.ccys.db.rely.service.impl.BaseServiceImpl;
import com.ccys.db.vo.doctor.doctorSetting.AcronymListVo;
import com.ccys.doctor.service.DoctorAcronymsService;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author：XLY
 * @Date：2024/2/5 0005
 */
@Service
public class DoctorAcronymsServiceImpl extends BaseServiceImpl<TblDoctorAcronyms> implements DoctorAcronymsService {

    @Resource
    private TblDoctorSupportTabReadMapper mapper;

    @Override
    public AcronymListVo getAcronyms(String keyword, Integer is_default) {
        String curLoginUserId = UserUtil.getCurLoginUserId();
        String groupId = UserUtil.getCurLoginUserGroupId();
        AppPageDto.startPage();
        List<AcronymListVo.AcronymVo> acronyms = mapper.getAcronyms(curLoginUserId, keyword, groupId, is_default);
        PageInfo<AcronymListVo.AcronymVo> pageInfo = new PageInfo<>(acronyms);
        AcronymListVo res = new AcronymListVo();
        res.setAcronymlists(acronyms);
        res.setTotalPage(pageInfo.getPages());
        return res;
    }

    @Override
    public AcronymListVo getAcronymsByDoctorId(String doctorId) {
        String groupId = UserUtil.getCurLoginUserGroupId();
        List<AcronymListVo.AcronymVo> acronyms = mapper.getAcronyms(doctorId, null, groupId, null);
        AcronymListVo res = new AcronymListVo();
        res.setAcronymlists(acronyms);
        return res;
    }

}
